home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / OpenTptSerial.p < prev    next >
Encoding:
Text File  |  1996-02-13  |  5.9 KB  |  202 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OpenTptSerial.p
  3.  
  4.      Contains:    Definitions for Serial Port
  5.  
  6.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  7.                  All rights reserved.
  8.  
  9. }
  10.  
  11. {$IFC UNDEFINED UsingIncludes}
  12. {$SETC UsingIncludes := 0}
  13. {$ENDC}
  14.  
  15. {$IFC NOT UsingIncludes}
  16.  UNIT OpenTptSerial;
  17.  INTERFACE
  18. {$ENDC}
  19.  
  20. {$IFC UNDEFINED __OPENTPTSERIAL__}
  21. {$SETC __OPENTPTSERIAL__ := 1}
  22.  
  23. {$I+}
  24. {$SETC OpenTptSerialIncludes := UsingIncludes}
  25. {$SETC UsingIncludes := 1}
  26.  
  27.  
  28. {$IFC UNDEFINED __OPENTRANSPORT__}
  29. {$I OpenTransport.p}
  30. {$ENDC}
  31. {    Types.p                                                        }
  32. {        ConditionalMacros.p                                        }
  33. {    MixedMode.p                                                    }
  34. {    Strings.p                                                    }
  35.  
  36. {$PUSH}
  37. {$ALIGN MAC68K}
  38. {$LibExport+}
  39.  
  40. CONST
  41.     COM_SERIAL                    = 'SERL';
  42.  
  43. {}
  44. { Version Number}
  45. {}
  46.     kSerialABVersion    =    '1.0';
  47. {}
  48. { Module Names}
  49. {}
  50.     kSerialABName    =    'serialAB';
  51.     kSerialName        =    'serial';
  52.     kSerialPortAName    =    'serialA';
  53.     kSerialPortBName    =    'serialB';
  54.     kSerialABModuleID            = 7200;
  55.  
  56.     kOTSerialFramingAsync        = $01;                            { Support Async serial mode             }
  57.     kOTSerialFramingHDLC        = $02;                            { Support HDLC synchronous serial mode    }
  58.     kOTSerialFramingSDLC        = $04;                            { Support SDLC synchronous serial mode    }
  59.     kOTSerialFramingAsyncPackets = $08;                            { Support Async "packet" serial mode    }
  60.  
  61. {******************************************************************************
  62. ** IOCTL Calls for Serial Drivers
  63. *******************************************************************************}
  64.      * Set DTR (0 = off, 1 = on)
  65.      }
  66.     I_SetSerialDTR                = 0+(MIOC_SRL_HIGH + 0);
  67.     kOTSerialSetDTROff            = 0;
  68.     kOTSerialSetDTROn            = 1;
  69. {
  70.      * Send a break on the line - kOTSerialSetBreakOff = off, kOTSerialSetBreakOn = on,
  71.      * Any other number is the number of milliseconds to leave break on, then
  72.      * auto shutoff
  73.      }
  74.     I_SetSerialBreak            = 0+(MIOC_SRL_HIGH + 1);
  75.     kOTSerialSetBreakOn            = $ffffffff;
  76.     kOTSerialSetBreakOff        = 0;
  77. {
  78.      * Force XOFF state - 0 = Unconditionally clear XOFF state, 1 = unconditionally set it
  79.      }
  80.     I_SetSerialXOffState        = 0+(MIOC_SRL_HIGH + 2);
  81.     kOTSerialForceXOffTrue        = 1;
  82.     kOTSerialForceXOffFalse        = 0;
  83. {
  84.      * Send an XON character
  85.      * 0 = send only if in XOFF state, 1 = send always
  86.      }
  87.     I_SetSerialXOn                = 0+(MIOC_SRL_HIGH + 3);
  88.     kOTSerialSendXOnAlways        = 1;
  89.     kOTSerialSendXOnIfXOffTrue    = 0;
  90. {
  91.      * Send an XOFF character
  92.      * 0 = send only if in XON state, 1 = send always
  93.      }
  94.     I_SetSerialXOff                = 0+(MIOC_SRL_HIGH + 4);
  95.     kOTSerialSendXOffAlways        = 1;
  96.     kOTSerialSendXOffIfXOnTrue    = 0;
  97.  
  98. {******************************************************************************
  99. ** Option Management for Serial Drivers
  100. *******************************************************************************}
  101. {
  102. ** These options are all 4-byte values.
  103. ** BaudRate is the baud rate.
  104. ** DataBits is the number of data bits.
  105. ** StopBits is the number of stop bits times 10.
  106. ** Parity is an enum
  107. }
  108.     SERIAL_OPT_BAUDRATE            = $0100;                        { UInt32    }
  109.     SERIAL_OPT_DATABITS            = $0101;                        { UInt32    }
  110.     SERIAL_OPT_STOPBITS            = $0102;                        { UInt32 10, 15 or 20 for 1, 1.5 or 2    }
  111.     SERIAL_OPT_PARITY            = $0103;                        { UInt32    }
  112.  
  113.     kOTSerialNoParity            = 0;
  114.     kOTSerialOddParity            = 1;
  115.     kOTSerialEvenParity            = 2;
  116.  
  117. {}
  118. { The "Status" option is a 4-byte value option that is ReadOnly}
  119. { It returns a bitmap of the current serial status}
  120. {}
  121.     SERIAL_OPT_STATUS            = $0104;
  122.     kOTSerialSwOverRunErr        = $01;
  123.     kOTSerialBreakOn            = $08;
  124.     kOTSerialParityErr            = $10;
  125.     kOTSerialOverrunErr            = $20;
  126.     kOTSerialFramingErr            = $40;
  127.     kOTSerialXOffSent            = $0010000;
  128.     kOTSerialDTRNegated            = $0020000;
  129.     kOTSerialCTLHold            = $0040000;
  130.     kOTSerialXOffHold            = $0080000;
  131.     kOTSerialOutputBreakOn        = $1000000;
  132.  
  133. {}
  134. { The "Handshake" option defines what kind of handshaking the serial port}
  135. { will do for line flow control.  The value is a 32-bit value defined by}
  136. { the function or macro SerialHandshakeData below.}
  137. { For no handshake, or CTS handshake, the onChar and offChar parameters}
  138. { are ignored.}
  139. {}
  140.     SERIAL_OPT_HANDSHAKE        = $0105;
  141.  
  142. {}
  143. { These are bits to enable specific types of handshaking}
  144. {}
  145.     kOTSerialXOnOffInputHandshake = 1;                            { Want XOn/XOff handshake for incoming characters    }
  146.     kOTSerialXOnOffOutputHandshake = 2;                            { Want XOn/XOff handshake for outgoing characters    }
  147.     kOTSerialCTSInputHandshake    = 4;                            { Want CTS handshake for incoming characters        }
  148.     kOTSerialDTROutputHandshake    = 8;                            { Want DTR handshake for outoing characters        }
  149.  
  150.     SERIAL_OPT_RCVTIMEOUT        = $0106;
  151.  
  152. {}
  153. { This option defines how characters with parity errors are handled.}
  154. { A 0 value will disable all replacement.  A single character value in the low}
  155. { byte designates the replacement character.  When characters are received with a }
  156. { parity error, they are replaced by this specified character.  If a valid incoming}
  157. { character matches the replacement character, then the received character's msb is}
  158. { cleared. For this situation, the alternate character is used, if specified in bits}
  159. { 8 through 15 of the option long, with 0xff being place in bits 16 through 23.}
  160. { Whenever a valid character is received that matches the first replacement character,}
  161. { it is replaced with this alternate character.}
  162. {}
  163.     SERIAL_OPT_ERRORCHARACTER    = $0107;
  164.  
  165.     SERIAL_OPT_EXTCLOCK            = $0108;
  166.  
  167. {}
  168. { The "BurstMode" option informs the serial driver that it should continue looping,}
  169. { reading incoming characters, rather than waiting for an interrupt for each character.}
  170. { This option may not be supported by all Serial driver}
  171. {}
  172.     SERIAL_OPT_BURSTMODE        = $0109;
  173.  
  174. {}
  175. { Default attributes for the serial ports}
  176. {}
  177.     kOTSerialDefaultBaudRate    = 19200;
  178.     kOTSerialDefaultDataBits    = 8;
  179.     kOTSerialDefaultStopBits    = 10;
  180.     kOTSerialDefaultParity        = kOTSerialNoParity;
  181.     kOTSerialDefaultHandshake    = 0;
  182.     kOTSerialDefaultOnChar        = $11;                            { Control-Q}
  183.     kOTSerialDefaultOffChar        = $13;                            { Control-S}
  184.     kOTSerialDefaultSndBufSize    = 128;
  185.     kOTSerialDefaultRcvBufSize    = 128;
  186.     kOTSerialDefaultSndLoWat    = 96;
  187.     kOTSerialDefaultRcvLoWat    = 1;
  188.     kOTSerialDefaultRcvTimeout    = 4;
  189.  
  190.  
  191. {$ALIGN RESET}
  192. {$POP}
  193.  
  194. {$SETC UsingIncludes := OpenTptSerialIncludes}
  195.  
  196. {$ENDC} {__OPENTPTSERIAL__}
  197.  
  198. {$IFC NOT UsingIncludes}
  199.  END.
  200. {$ENDC}
  201.